<%-- 
    Document   : index
    Created on : Sep 8, 2013, 2:29:59 AM
    Author     : Administrator
--%>

<%@page import="java.math.BigDecimal"%>
<%@page import="Model.Dao.DAODanhMucSanPham"%>
<%@page import="java.util.Date"%>
<%@page import="Controler.CXuLy"%>
<%@page import="Model.Pojo.Khachhang"%>
<%@page import="Model.Pojo.Sanpham"%>
<%@page import="java.util.List"%>
<%@page import="Model.Pojo.Danhmucsanpham"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<head>
    <meta charset="utf-8" />
    <title><%
        //Cap nhat thong tin khach hang
        if (request.getAttribute("CAP_NHAT_SAN_PHAM") != null)
        {
            out.print("Cập nhật sản phẩm");
        }
        else
        {
            out.print("Thêm sản phẩm");
        }
        %></title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport" />
    <meta content="" name="description" />
    <meta content="Mosaddek" name="author" />
    <link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="assets/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" />
    <link href="assets/bootstrap/css/bootstrap-fileupload.css" rel="stylesheet" />
    <link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <link href="css/style.css" rel="stylesheet" />
    <link href="css/style-responsive.css" rel="stylesheet" />
    <link href="css/style-default.css" rel="stylesheet" id="style_color" />

    <link href="assets/fancybox/source/jquery.fancybox.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="assets/uniform/css/uniform.default.css" />

    <link rel="stylesheet" type="text/css" href="assets/chosen-bootstrap/chosen/chosen.css" />
    <link rel="stylesheet" type="text/css" href="assets/jquery-tags-input/jquery.tagsinput.css" />
    <link rel="stylesheet" type="text/css" href="assets/clockface/css/clockface.css" />
    <link rel="stylesheet" type="text/css" href="assets/bootstrap-wysihtml5/bootstrap-wysihtml5.css" />
    <link rel="stylesheet" type="text/css" href="assets/bootstrap-datepicker/css/datepicker.css" />
    <link rel="stylesheet" type="text/css" href="assets/bootstrap-timepicker/compiled/timepicker.css" />
    <link rel="stylesheet" type="text/css" href="assets/bootstrap-colorpicker/css/colorpicker.css" />
    <link rel="stylesheet" href="assets/bootstrap-toggle-buttons/static/stylesheets/bootstrap-toggle-buttons.css" />
    <link rel="stylesheet" type="text/css" href="assets/bootstrap-daterangepicker/daterangepicker.css" />

    <link href="assets/dropzone/css/basic.css" rel="stylesheet"/>

    <link href="assets/dropzone/css/dropzone.css" rel="stylesheet"/>

</head>
<body class="fixed-top">
    <jsp:include page="User Control/banner.jsp" flush="true"></jsp:include>

        <div id="container" class="row-fluid">
        <jsp:include page="User Control/menu.jsp" flush="true"></jsp:include>
            <div id="main-content">
                <div class="container-fluid">
                <jsp:include page="User Control/title.jsp" flush="true"></jsp:include>
                    <div class="row-fluid">
                        <div class="span12">
                            <!-- BEGIN VALIDATION STATES-->
                            <div class="widget red">
                                <div class="widget-title">
                                    <h4><i class=" icon-key"></i><%
                                        //Cap nhat thong tin khach hang
                                        if (request.getAttribute("CAP_NHAT_SAN_PHAM") != null)
                                        {
                                            out.print("Cập nhật sản phẩm");
                                        }
                                        else
                                        {
                                            out.print("Thêm sản phẩm");
                                        }
                                    %></h4>
                                <span class="tools">
                                    <a href="javascript:;" class="icon-chevron-down"></a>
                                    <a href="javascript:;" class="icon-remove"></a>
                                </span>
                            </div>
                            <div class="widget-body form">
                                <%

                                    String error = (String) request.getAttribute(
                                            "ERROR");
                                    Object obj = request.getAttribute("QUAN_LY_SAN_PHAM");
                                    if (obj == null)
                                    {
                                        error = "The page you request was not found.";
                                    }
                                    if (error == null && obj != null)
                                    {
                                        Sanpham dtoSP = (Sanpham) request.getAttribute(
                                                "CHI_TIET_SAN_PHAM");
                                %>
                                <jsp:useBean id="chitietsanpham" class="Model.Pojo.Sanpham">
                                    <%
                                        if (dtoSP == null)
                                        {
                                            dtoSP = new Sanpham(new Danhmucsanpham(0),
                                                                "SP-" + String.
                                                    valueOf((new Date()).getTime()), "", BigDecimal.
                                                    valueOf(0),
                                                                0, "", "",
                                                                "", new Date(), 0);
                                        }
                                    %>


                                </jsp:useBean>
                                <!-- BEGIN FORM-->
                                <form class="form-horizontal" method="post" action="them-san-pham.htm">
                                    <div id="tabsleft" class="tabbable tabs-left">
                                        <ul>
                                            <li><a href="#tabsleft-tab1" data-toggle="tab"><span class="strong">Bước 1</span> <span class="muted">Thông tin sản phẩm</span></a></li>
                                            <li><a href="#tabsleft-tab2" data-toggle="tab"><span class="strong">Bước 2</span> <span class="muted">Giá sản phẩm & chiết khấu</span></a></a></li>
                                            <li><a href="#tabsleft-tab3" data-toggle="tab"><span class="strong">Bước 3</span> <span class="muted">Bài đăng sản phẩm</span></a></a></li>
                                        </ul>
                                        <div class="progress progress-info progress-striped">
                                            <div class="bar"></div>
                                        </div>
                                        <div class="tab-content">
                                            <div class="tab-pane" id="tabsleft-tab1">
                                                <h3>Thông tin sản phẩm</h3>
                                                <div class="control-group">
                                                    <label class="control-label">Danh mục</label>
                                                    <div class="controls">
                                                        <%
                                                            List<Danhmucsanpham> list = (new DAODanhMucSanPham()).
                                                                    DanhSachDanhMuc();
                                                        %>
                                                        <select class="span6 chzn-select" name="cboDanhMucSanPham" data-placeholder="Chọn ..." tabindex="1">
                                                            <%
                                                                int id_dmsp = 0;
                                                                if (chitietsanpham.
                                                                        getDanhmucsanpham() != null)
                                                                {
                                                                    id_dmsp = chitietsanpham.
                                                                            getDanhmucsanpham().
                                                                            getId();
                                                                }

                                                                for (int i = 0; i < list.size(); i++)
                                                                {
                                                                    if (list.get(i).getId() == id_dmsp)
                                                                    {
                                                                        out.print(
                                                                                "<option seleted=selected value=\"" + list.
                                                                                get(i).getId() + "\">" + list.
                                                                                get(i).
                                                                                getTendanhmuc() + "</option>");
                                                                        continue;
                                                                    }
                                                                    out.print(
                                                                            "<option value=\"" + list.
                                                                            get(i).getId() + "\">" + list.
                                                                            get(i).getTendanhmuc() + "</option>");
                                                                }
                                                            %>
                                                        </select>
                                                    </div>

                                                </div>
                                                <div class="control-group ">
                                                    <label for="cemail" class="control-label">Mã sản phẩm (*)</label>
                                                    <div class="controls">
                                                        <input class="span6 " id="cname" name="txtMaSanPham" value="<%=dtoSP.getMasp()%>" readonly="" minlength="2" type="text" required />
                                                    </div>
                                                </div>
                                                <div class="control-group ">
                                                    <label for="cemail" class="control-label">Tên sản phẩm (*)</label>
                                                    <div class="controls">
                                                        <input class="span6 " id="cname" name="txtTenSanPham" value="<%=dtoSP.getTensp()%>" minlength="2" type="text" required />
                                                    </div>
                                                </div>
                                                <div class="control-group ">
                                                    <label for="cemail" class="control-label">Số lượng (*)</label>
                                                    <div class="controls">
                                                        <input class="span6 " id="cname" name="txtSoLuong" value="<%=dtoSP.getSoluong()%>" minlength="2" type="text" required />
                                                    </div>
                                                </div>
                                                <hr/>


                                            </div>
                                            <div class="tab-pane" id="tabsleft-tab2">
                                                <h3>Thông tin giá cả</h3>
                                                <div class="control-group">
                                                    <label class="control-label">Giá gốc (*)</label>
                                                    <div class="controls">
                                                        <div class="input-prepend input-append">
                                                            <input type="text" class=" " name="txtGiaGoc" value='<%=String.valueOf(dtoSP.getGiagoc()).replace(",", "").replace(
                                                                    ".0000", "")%>' required=""><span class="add-on">.000</span><span class="add-on">VNĐ</span>
                                                        </div>
                                                    </div>
                                                </div><div class="control-group">
                                                    <label class="control-label">Chiết khấu (*)</label>
                                                    <div class="controls">
                                                        <div class="input-prepend input-append">
                                                            <input type="text" class=" " name="txtChietKhau" value="<%=dtoSP.getGiamgia()%>" required=""><span class="add-on">%</span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="control-group">
                                                    <label class="control-label">Ngày kết thúc bán</label>

                                                    <div class="controls">
                                                        <div data-date-viewmode="years" data-date-format="dd/mm/yyyy" data-date="" id="dpYears" class="input-append date">
                                                            <input type="text" readonly="" name="txtNgayKetThuc" value="<%=CXuLy.ConvertDateToString(dtoSP.getNgayketthuc())%>" size="16" class="m-ctrl-medium">
                                                            <span class="add-on"><i class="icon-calendar"></i></span>
                                                        </div>
                                                    </div>
                                                </div>
                                                <hr/>
                                                <br/><br/>
                                                <div class="clearfix"></div>
                                            </div>
                                            <div class="tab-pane" id="tabsleft-tab3">
                                                <h3>Bài đăng sản phẩm</h3>
                                                <div class="control-group">
                                                    <label class="control-label">Tiêu đề sản phẩm</label>
                                                    <div class="controls">
                                                        <textarea rows="3" name="txtTieuDeSanPham"  class="span6 " required><%=dtoSP.getNoidungngan()%></textarea>
                                                    </div>
                                                </div>
                                                <div class="control-group">
                                                    <label class="control-label">Bài viết sản phẩm</label>
                                                    <div class="controls">
                                                        <textarea class="span12 wysihtmleditor5" name="txtBaiVietSanPham"  style="height: 400px" required><%=dtoSP.getNoidungdai()%></textarea>
                                                    </div>
                                                </div>
                                                <button class="btn btn-large btn-primary" type="submit" ><i></i>Lưu thông tin</button>
                                                <div class="clearfix"></div>
                                            </div>
                                            <ul class="pager wizard">
                                                <li class="previous first"><a href="javascript:;">First</a></li>
                                                <li class="previous"><a href="javascript:;">Previous</a></li>
                                                <li class="next last"><a href="javascript:;">Last</a></li>
                                                <li class="next"><a href="javascript:;">Next</a></li>
                                                <li class="next finish" style="display:none;">
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </form>
                                <%                        }
                                else
                                {
                                %>
                                <h1 style="color: red"><%=error%></h1>
                                <%                                            }
                                %>
                                <!-- END FORM-->
                            </div>
                        </div>
                        <!-- END VALIDATION STATES-->
                    </div>
                </div>
            </div>
        </div>
        <!-------------------------------- ket thuc nội dung--------------------------------------->

    </div>

    <!--------------------------------footer--------------------------------------->
    <jsp:include page="User Control/footer.jsp" flush="true"></jsp:include>

    <!--------------------------------end footer--------------------------------------->
    <script src="js/jquery-1.8.3.min.js"></script>
    <script src="js/jquery.nicescroll.js" type="text/javascript"></script>
    <script type="text/javascript" src="assets/ckeditor/ckeditor.js"></script>
    <script src="assets/bootstrap/js/bootstrap.min.js"></script>
    <script src="assets/dropzone/dropzone.js"></script>
    <script type="text/javascript" src="assets/bootstrap/js/bootstrap-fileupload.js"></script>
    <script src="assets/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script>
    <script src="js/jquery.blockui.js"></script>
    <!-- ie8 fixes -->
    <!--[if lt IE 9]>
    <script src="js/excanvas.js"></script>
    <script src="js/respond.js"></script>
    <![endif]-->

    <script type="text/javascript" src="assets/bootstrap-toggle-buttons/static/js/jquery.toggle.buttons.js"></script>
    <script type="text/javascript" src="assets/chosen-bootstrap/chosen/chosen.jquery.min.js"></script>
    <script type="text/javascript" src="assets/uniform/jquery.uniform.min.js"></script>
    <script type="text/javascript" src="assets/bootstrap-wysihtml5/wysihtml5-0.3.0.js"></script>
    <script type="text/javascript" src="assets/bootstrap-wysihtml5/bootstrap-wysihtml5.js"></script>
    <script type="text/javascript" src="assets/clockface/js/clockface.js"></script>
    <script type="text/javascript" src="assets/jquery-tags-input/jquery.tagsinput.min.js"></script>
    <script type="text/javascript" src="assets/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script type="text/javascript" src="assets/bootstrap-daterangepicker/date.js"></script>
    <script type="text/javascript" src="assets/bootstrap-daterangepicker/daterangepicker.js"></script>
    <script type="text/javascript" src="assets/bootstrap-colorpicker/js/bootstrap-colorpicker.js"></script>
    <script type="text/javascript" src="assets/bootstrap-timepicker/js/bootstrap-timepicker.js"></script>
    <script type="text/javascript" src="assets/bootstrap-inputmask/bootstrap-inputmask.min.js"></script>
    <script src="assets/fancybox/source/jquery.fancybox.pack.js"></script>


    <!--common script for all pages-->
    <script src="js/common-scripts.js"></script>

    <!--script for this page-->
    <script src="js/form-wizard.js"></script>
    <script src="js/form-component.js"></script>



    <!--script for this page-->
    <!-- END JAVASCRIPTS -->
    <script>
        $(function() {
            $(" input[type=radio], input[type=checkbox]").uniform();
        });
    </script>
</body>
</html>